package com.mimosa.util.constant;

import org.apache.commons.lang3.StringUtils;

/**
 * 字符串常量的工具类
 * 
 * @date 2012-3-10
 * @filename StringConstUtil.java
 * @author Yanlei Han
 */
public final class StringConstUtil {
	/**
	 * @符号
	 */
	public static final String AT = "@";
	/**
	 * 左大括号
	 */
	public static final String LEFT_BRACE = "{";
	/**
	 * 右大括号
	 */
	public static final String RIGHT_BRACE = "}";
	/**
	 * 左小括号
	 */
	public static final String LEFT_BRACKET = "(";
	/**
	 * 右小括号
	 */
	public static final String RIGHT_BRACKET = ")";
	/**
	 * 左中括号
	 */
	public static final String LEFT_SQUARE_BRACKET = "[";
	/**
	 * 右中括号
	 */
	public static final String RIGHT_SQUARE_BRACKET = "]";
	/**
	 * 井号
	 */
	public static final String NUMBER_SIGN = "#";
	/**
	 * 与操作符
	 */
	public static final String AMPERS_AND = "&";
	/**
	 * 或操作符
	 */
	public static final String AMPERS_OR = "|";

	// 标点符号信息
	/**
	 * 冒号
	 */
	public static final String COLON = ":";
	/**
	 * TAB键
	 */
	public static final String TAB = "\t";
	/**
	 * 分号
	 */
	public static final String SEMICOLON = ":";
	/**
	 * 逗号
	 */
	public static final String COMMA = ",";
	/**
	 * 句号
	 */
	public static final String DOT = ".";
	/**
	 * 双引号
	 */
	public static final String DOUBLE_QUOTE = "\"";
	/**
	 * 单引号
	 */
	public static final String SINGLE_QUOTE = "\'";
	/**
	 * 空格
	 */
	public static final String SPACE = " ";
	/**
	 * 加号
	 */
	public static final String PLUS = "+";
	/**
	 * 减号
	 */
	public static final String MINUS = "-";
	/**
	 * 下划线
	 */
	public static final String UNDER_LINE = "_";
	/**
	 * 除号
	 */
	public static final String DIVEDE = "/";
	/**
	 * 问号
	 */
	public static final String QUESTION = "?";
	/**
	 * 百分号
	 */
	public static final String PERCENTAGE = "%";
	/**
	 * 美元符号
	 */
	public static final String DOLLAR_SIGN = "$";
	/**
	 * 等于符号
	 */
	public static final String EQUAL_SIGN = "=";
	/**
	 * 乘号
	 */
	public static final String MULTIPLE = "*";
	/**
	 * 空白字符串
	 */
	public static final String EMPTY = "";
	/**
	 * 零
	 */
	public static final String ZERO = "0";
	/**
	 * 正1
	 */
	public static final String PLUS_ONE = "1";
	/**
	 * 负1
	 */
	public static final String MINUS_ONE = "-1";
	/**
	 * 逻辑与操作符
	 */
	public static final String LOGIC_AND = "AND";
	/**
	 * 逻辑或操作符OR
	 */
	public static final String LOGIC_OR = "OR";

	public static String Q2BChange(String input) {
		String result = StringUtils.EMPTY;
		if (StringUtils.isNotBlank(input)) {
			char[] str = input.toCharArray();
			for (int i = 0; i < str.length; i++) {
				// 获取当前字符的unicode编码
				int code = str[i];
				// 在这个unicode编码范围中的是所有的英文字母以及各种字符
				if (code >= 65281 && code <= 65373) {
					// 把全角字符的unicode编码转换为对应半角字符的unicode码
					result += (char) (str[i] - 65248);
				} // 空格
				else if (code == 12288) {
					result += (char) (str[i] - 12288 + 32);
				} else if (code == 65377) {
					result += (char) (12290);
				} else if (code == 12539) {
					result += (char) (183);
				}
				// 如果是特殊字符TM 并且是需要转换的所作操作
				else if (code == 8482) {

				}
				// 特殊字符 ‘·’的转化
				else if (code == 8226) {
					result += (char) (183);
				} else {
					result += str[i];
				}
			}
		}
		return result;
	}
}